<!--  从业者-个人求职-我的面试  -->
<template>
	<view class="container">
		<!-- 顶部选项卡 -->
		<u-tabs :list="tabList" :current="currentTab" @change="changeTab"></u-tabs>

		<!-- 简历列表 -->
		<view v-if="resumeList.length > 0">
			<view v-for="(item, index) in filteredResumes" :key="index" class="resume-item">
				<view class="resume-header">
					<text class="user-name">{{ item.tdyq_gw_name }}</text>
					<view class="resume-footer">
						<text v-if="item.cy_msstate == 0 " class="status" :class="{'unviewed': item.cy_isread === 0, 
                                'viewed': item.cy_isread === 1,
                                'interview': item.cy_isread === '已邀面试',
                                'rejected': item.cy_isread === '不合适'}">{{ item.cy_isread == 0 ? '未查看' : '已查看' }}</text>
						<text v-else class="status" :class="{'unviewed': item.cy_msstate === 1,
						                    'viewed': item.cy_msstate === 2,
						                    'interview': item.cy_isread === '已邀面试',
						                    'rejected': item.cy_isread === '不合适'}">{{ item.cy_msstate == 1 ? '不合适' : '已邀请面试' }}</text>
						
					</view>
				</view>
				<view class="resume-footer">
					<text>{{ item.jginfo.yyzz.yyzz_name }} </text>
				</view>
				<view class="resume-footer">
					<text class="time">面试时间：{{ item.tdyq_msdate }}</text>
				</view>
				<view class="resume-footer">
					<text class="time">面试地址：{{ item.tdyq_msaddr }}</text>
				</view>
				<view class="resume-footer">
					<text>联系人：{{item.tdyq_msusername}} {{ item.tdyq_msphoneno }} </text>
				</view>
				<view class="resume-footer">
					<text>微信号：{{ item.tdyq_mswxid }}</text>
				</view>

				<!-- 按钮 -->
				<view class="course-actions">
					<view class="course-category" v-if="item.cy_isread == 0 || item.cy_isread == 1">
						<u-button v-if="item.cy_msstate != 1 " class="category-but" type="default" :disabled="isDisabledA"  :custom-style="btuStyle" size="medium"  shape="circle" @click="butNoheshi(index)">
							不合适
						</u-button>
						<u-button  v-if="item.cy_msstate != 2 " type="default" size="medium" :disabled="isDisabledB" :custom-style="btuStyle"  shape="circle"  @click="butYes(index)">
							同意
						</u-button>
					</view>
					<!-- 					<u-button v-else type="success" size="medium" shape="circle" @click="studyCourse(course.id)">
						学习
					</u-button> -->
				</view>
			</view>
		</view>

		<!-- 空状态 -->
		<u-empty v-else mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 按钮
				btuStyle: {
					"backgroundColor": "#03B8CD",
					"color": "#ffffff"
				},
				isDisabledA: false,
				isDisabledB: false,
				currentTab: 0,
				tabList: [{
						name: '全部'
					},
					{
						name: '未查看'
					},
					{
						name: '已查看'
					}
				],
				resumeList: [{
						position: '康养师',
						company: '公司名称',
						city: '福州-鼓楼区',
						deliveryTime: '2025-05-23',
						status: '未查看',
						contacts: 'XXXXX',
						phone: '66767676767676',
						weixin: '2323232'
					},
					{
						position: '康养师',
						company: '公司名称',
						city: '福州-鼓楼区',
						deliveryTime: '2025-05-23',
						status: '已查看',
						contacts: 'XXXXX',
						phone: '66767676767676',
						weixin: '2323232'
					},
					{
						position: '康养师',
						company: '公司名称',
						city: '福州-鼓楼区',
						deliveryTime: '2025-05-23',
						contacts: 'XXXXX',
						phone: '66767676767676',
						weixin: '2323232',
						status: '已邀面试'
					},
					{
						position: '康养师',
						company: '公司名称',
						city: '福州-鼓楼区',
						deliveryTime: '2025-05-23',
						contacts: 'XXXXX',
						phone: '66767676767676',
						weixin: '2323232',
						status: '不合适'
					}
				],
				gwData: [],
				tdTime: []
			}
		},
		computed: {
			filteredResumes() {
				if (this.currentTab === 0) return this.gwData
				if (this.currentTab === 1) return this.gwData.filter(item => item.cy_isread === 0)
				if (this.currentTab === 2) return this.gwData.filter(item => item.cy_isread === 1)
				return this.gwData
			}

		},
		onShow() {
			this.yqlist()
	
		},
		methods: {
			yqlist() {
				this.$u.api.congyebeiyqlist({
					"usercode": uni.getStorageSync('usercode'), ///#从业者code
				}).then(res => {
					console.log('从业者邀请列表：', res);
					this.gwData = res.data.base_info
					// 根据读回来的邀请，获取个人简历
					// for (var i = 0; i < this.gwData.length; i++) {
					// 	this.$u.api.queryjlfull({
					// 		usercode: this.resumeList[i].user_code
					// 	}).then(res => {
					// 		this.resume_name.push(res.data.base_info.base.jlbi_name)
				
					// 	})
					// }
					// console.log('增加了个人简历：', this.resume_name)
				
				})
			},
			changeTab(index) {
				this.currentTab = index
			},
			// 不合适
			butNoheshi(index) {
				this.$u.api.updatecyyqmsstate({
					"tbyqcode": this.gwData[index].tdyq_code,//#邀请面试的code
					"cymsstate":"1" //#面试状态, 默认为0未处理，1不合适，2已同意，
				}).then(res => {
					console.log('不合适：',res)
					// this.isDisabledA = true
					// this.isDisabledB = false
					this.yqlist()
				})
				
			},
			// 同意
			butYes(index) {
				this.$u.api.updatecyyqmsstate({
					"tbyqcode": this.gwData[index].tdyq_code,//#邀请面试的code
					"cymsstate":"2" //#面试状态, 默认为0未处理，1不合适，2已同意，
				}).then(res => {
					console.log('不合适：',res)
					// this.isDisabledA = true
					// this.isDisabledB = false
					this.yqlist()
					
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 20rpx;
	}

	.resume-item {
		padding: 30rpx;
		margin-bottom: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
	}

	.resume-header {
		display: flex;
		justify-content: space-between;
		margin-bottom: 15rpx;

		.user-name {
			font-size: 32rpx;
			font-weight: bold;
		}

		.position {
			font-size: 28rpx;
			color: #666;
		}
	}

	.resume-info {
		font-size: 26rpx;
		color: #888;
		margin-bottom: 20rpx;
	}

	.resume-footer {
		display: flex;
		justify-content: space-between;
		font-size: 24rpx;
		color: #999;

		.status {
			&.unviewed {
				color: #f56c6c;
			}

			&.viewed {
				color: #409eff;
			}

			&.interview {
				color: #67c23a;
			}

			&.rejected {
				color: #909399;
			}
		}
	}

	// 按钮
	.course-actions {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top: 15rpx;


		.course-category {
			// display: flex;
			// justify-content: flex-end;
			font-size: 24rpx;
			color: #999;
			background-color: #f5f7fa;
			padding: 6rpx 12rpx;
			border-radius: 20rpx;
			margin-left: 100rpx;
		}

		.category-but {
			margin: 0 10px;
		}

		/deep/ .u-size-medium {
			height: 30px;
			line-height: 30px;

		}
	}
</style>